package com.itholmes.utils;

import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;

public class ConnectionsPool {
	
	//我们使用map来操作!!实现线程id作为标识的数据库连接池。
	static Map<Long,Connection> pool = new HashMap<Long,Connection>();

	//往连接池中放入连接connection
	public static void putConnection(Connection con) {
		pool.put(Thread.currentThread().getId(), con);
	}
	
	//依据线程id，在连接池中取连接connection
	public static Connection getConnection() {
		return pool.get(Thread.currentThread().getId());
	}
	
	//将线程从数据库池中移除
	public static Connection remove(Connection con) {
		 return pool.remove(Thread.currentThread().getId());
	}
	
}
